package com.jet.merchant.gate;

import com.jet.merchant.domain.dto.AccountLogDto;
import com.jet.merchant.service.IClerkAccountLoginLogService;
import com.jet.core.result.ResultJson;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;

/**
 * @author dcl
 * @since 2024/4/1 11:13
 */
@RestController
@RequestMapping("/gate/clerk/account-log")
public class GateAccountLogController {

    private final IClerkAccountLoginLogService clerkAccountLoginLogService;

    public GateAccountLogController(IClerkAccountLoginLogService clerkAccountLoginLogService) {
        this.clerkAccountLoginLogService = clerkAccountLoginLogService;
    }

    @PostMapping
    public ResultJson<Void> save(@RequestHeader long merchantNo,
                                 @RequestHeader long storeNo,
                                 @RequestHeader String accountId,
                                 @RequestBody AccountLogDto dto,
                                 HttpServletRequest request) {
        clerkAccountLoginLogService.save(request, accountId, dto.getType(), LocalDateTime.now(), dto.getPlatform());
        return ResultJson.ok();
    }
}
